<?php
// +----------------------------------------------------------------------
// | EtrolPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Author:LJQ <liujiqi@etrol.com>
// +-----------------------------------------------------------------------

namespace app\rehearse\model;

use app\common\model\Base;
use app\duty\model\Events;

/**
 * 救援行动管理
 */
class Record extends Base{
  protected $name = 'rescueexec';
  protected $createTime = 'createTime';
  protected $updateTime = 'updateTime';
  

  public function getExecTimeAttr($value,$data){
    if($data['execTime']){
      return date('Y-m-d H:i:s',$data['execTime']);
    }
  }

  public function setExecTimeAttr($data){
     if(is_numeric($data)){
      return time();
    }else{
      return strtotime($data);
    }

  }



  public function events(){

    return $this->hasOne(Events::class,'id','eventId')->bind('title');

  }

    public function records(){
    return $this->hasMany('Recorddetail','rescueExecId','id');
  }



}